package com.qf.form;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.qf.serializer.Date2LongSerializer;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;

public class UserForm {



    @NotBlank(message = "用户名是必填项,岂能为空!")    // username != null && !username.eq("")
    @JsonProperty(value = "name")
    private String username;

    @NotBlank(message = "密码是必填项,岂能为空!")
    private String password;

    @NotNull(message = "年龄为必填项,岂能为空")
    @Min(value = 0,message = "最小年龄为0岁")
    @Max(value = 150,message = "年龄最大值为150")
    private Integer age;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonSerialize(using = Date2LongSerializer.class)
    private Date birthday;



    @JsonIgnore
    private String nickname;

    @JsonIgnore
    private List<String> hobby;


    public List<String> getHobby() {
        return hobby;
    }

    public void setHobby(List<String> hobby) {
        this.hobby = hobby;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }
}
